package com.songcha.module_bookshelf.ui.decoration

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.songcha.library_common.util.dp2px

class BookShelfItemDecoration:RecyclerView.ItemDecoration() {
    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        val lp=view.layoutParams as GridLayoutManager.LayoutParams

        if(lp.spanIndex%3==0){
            outRect.top=10.dp2px()
            outRect.left=10.dp2px()
            outRect.right=14.dp2px()
            outRect.bottom=10.dp2px()
        }else if(lp.spanIndex%3==1){
            outRect.top=10.dp2px()
            outRect.left=14.dp2px()
            outRect.right=14.dp2px()
            outRect.bottom=10.dp2px()
        }else if(lp.spanIndex%3==2){
            outRect.top=10.dp2px()
            outRect.left=14.dp2px()
            outRect.right=10.dp2px()
            outRect.bottom=10.dp2px()
        }
    }
}